/*
 * @lc app=leetcode.cn id=1576 lang=javascript
 *
 * [1576] 替换所有的问号
 */

// @lc code=start
/**
 * @param {string} s
 * @return {string}
 */
var modifyString = function (s) {
  return s.split('').map((item, index, arr) => {
    if (item === '?') {
      if (index % 2 === 0) {
        let sign = 'a'
        if (arr[index - 1] === 'a' || arr[index + 1] === 'a') {
          sign = 'b';
          if (arr[index - 1] === 'b' || arr[index + 1] === 'b') {
            sign = 'c'
          }
        }
        return sign;
      } else {
        let sign = 'd'
        if (arr[index - 1] === 'd' || arr[index + 1] === 'd') {
          sign = 'e';
          if (arr[index - 1] === 'e' || arr[index + 1] === 'e') {
            sign = 'f';
          }
        }
        return sign;
      }
    }
    return item;
  }).join('');
};
// @lc code=end

